package com.ruoyi.system.mapper;

import com.ruoyi.system.api.domain.Attachment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 附件Mapper接口
 * 
 * @author luogongquan
 * @date 2024-09-18
 */
public interface AttachmentMapper 
{
    /**
     * 查询附件
     * 
     * @param id 附件主键
     * @return 附件
     */
    public Attachment selectAttachmentById(Long id);

    /**
     * 查询附件列表
     * 
     * @param attachment 附件
     * @return 附件集合
     */
    public List<Attachment> selectAttachmentList(Attachment attachment);

    /**
     * 新增附件
     * 
     * @param attachment 附件
     * @return 结果
     */
    public int insertAttachment(Attachment attachment);
    /**
     * 新增附件
     *
     * @param attachment 附件
     * @return 结果
     */
    public int batchInsertAttachment(List<Attachment> attachment);

    /**
     * 修改附件
     * 
     * @param attachment 附件
     * @return 结果
     */
    public int updateAttachment(Attachment attachment);

    /**
     * 删除附件
     * 
     * @param id 附件主键
     * @return 结果
     */
    public int deleteAttachmentById(Long id);
    /**
     * 删除附件
     *
     * @param id 附件主键
     * @return 结果
     */
    public int deleteAttachmentByAssociatedIds(List<Long> id);
    /**
     * 删除附件
     *
     * @param associatedId 附件关联主体id
     * @return 结果
     */
    @Delete(" delete from attachment where associated_id = #{associatedId} ")
    int deleteAttachmentByAssociatedId(Long associatedId);

    /**
     * 批量删除附件
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAttachmentByIds(Long[] ids);

    @Select("select file_id,name from  attachment where associated_id = #{associatedId}")
    List<Attachment> getFileIdByAssociatedId(Long associatedId);
}
